﻿namespace FR.SAFTAnalyser.ViewModels.Pane
{
    using AvalonDock.Layout;
    using FR.SAFTAnalyser.ViewModels.Tools;
    using System.Windows;
    using System.Windows.Controls;

    public class PanesTemplateSelector : DataTemplateSelector
    {
        public PanesTemplateSelector()
        {

        }

        public DataTemplate CustomersViewTemplate { get; set; }
        public DataTemplate GeneralLedgerViewTemplate { get; set; }
        public DataTemplate GeneralLedgerEntriesViewTemplate { get; set; }
        public DataTemplate HeaderViewTemplate { get; set; }
        public DataTemplate InvoicesSummaryViewTemplate { get; set; }
        public DataTemplate InvoicesViewTemplate { get; set; }
        public DataTemplate InvoiceViewTemplate { get; set; }
        public DataTemplate WorkingDocumentsViewTemplate { get; set; }
        public DataTemplate MovementOfGoodsViewTemplate { get; set; }
        public DataTemplate ProductsViewTemplate { get; set; }
        public DataTemplate SaftViewTemplate { get; set; }
        public DataTemplate SuppierViewTemplate { get; set; }
        public DataTemplate TaxViewTemplate { get; set; }
        public DataTemplate PaymentsViewTemplate { get; set; }

        //stocks
        public DataTemplate StockHeaderTemplate { get; set; }
        public DataTemplate StockProductsTemplate { get; set; }

        //tools
        public DataTemplate ErrorMessagesViewTemplate { get; set; }
        public DataTemplate SaftPArtsViewTemplate { get; set; }
        public DataTemplate ConvertPemKeyTemplate { get; set; }
        public DataTemplate SaveBDTemplate { get; set; }
        public DataTemplate CreateHashFromUserInputTemplate { get; set; }

        public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            var itemAsLayoutContent = item as LayoutContent;

            if (item is SaftViewModel)
                return SaftViewTemplate;
            if (item is CustomersViewModel)
                return CustomersViewTemplate;
            if (item is GeneralLedgerViewModel)
                return GeneralLedgerViewTemplate;
            if (item is GeneralLedgerEntriesViewModel)
                return GeneralLedgerEntriesViewTemplate;
            if (item is HeaderViewModel)
                return HeaderViewTemplate;
            if (item is InvoicesSummaryViewModel)
                return InvoicesSummaryViewTemplate;
            if (item is InvoicesViewModel)
                return InvoicesViewTemplate;
            if (item is InvoiceViewModel)
                return InvoiceViewTemplate;
            if (item is WorkingDocumentsViewModel)
                return WorkingDocumentsViewTemplate;
            if (item is MovementOfGoodsViewModel)
                return MovementOfGoodsViewTemplate;
            if (item is ProdutsViewModel)
                return ProductsViewTemplate;
            if (item is SupplierViewModel)
                return SuppierViewTemplate;
            if (item is TaxViewModel)
                return TaxViewTemplate;
            if (item is PaymentsViewModel)
                return PaymentsViewTemplate;

            //stocks
            if (item is StockHeaderViewModel)
                return StockHeaderTemplate;
            if (item is StocksProductsViewModel)
                return StockProductsTemplate;

            //tools
            if (item is ConvertPemKeyViewModel)
                return ConvertPemKeyTemplate;
            if (item is ErrorMessagesViewModel)
                return ErrorMessagesViewTemplate;
            if (item is DocumentPartsViewModel)
                return SaftPArtsViewTemplate;
            if (item is SaveToBDViewModel)
                return SaveBDTemplate;
            if (item is CreateHashFromUserInputViewModel)
                return CreateHashFromUserInputTemplate;

            return base.SelectTemplate(item, container);
        }
    }
}
